/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa036is.servicesimplementation;

import cz.muni.fi.pa036is.daointerface.AddressDAO;
import cz.muni.fi.pa036is.dto.AddressTO;
import cz.muni.fi.pa036is.dtoconverters.AddressConverter;
import cz.muni.fi.pa036is.entity.Address;
import cz.muni.fi.pa036is.servicesinterface.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author jostri
 */
@Service
public class AddressServiceImpl implements AddressService {

				@Autowired
				private AddressDAO addressDAO;
				
				@Override
				public void addAddress(final AddressTO addressTO) {
								final Address address = AddressConverter.convertToAddress(addressTO);
        this.addressDAO.addAddress(address);
				}

				@Override
				public void editAddress(AddressTO addressTO) {
								final Address address = AddressConverter.convertToAddress(addressTO);
        this.addressDAO.editAddress(address);
				}

				@Override
				public void deleteAddress(Long id) {
								this.addressDAO.deleteAddress(id);
				}

				@Override
				public AddressTO getAddressByPerson(Long id) {
								return AddressConverter.convertToAddressTO(this.addressDAO.getAddressByPerson(id));
				}
				
}
